#include <bits/stdc++.h>
using namespace std;
const int N=100000;
int z[1000000];
int n,r[N],i,t,m,h,p[N],l,j,V,d[N],v[N],a[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(h=0;h<t;h++){
        cin>>n>>m>>l>>V;
        t=0;
        bool b[N]={0};
        for(i=0;i<n;i++)
            cin>>d[i]>>v[i]>>a[i];
        for(i=0;i<m;i++)
            cin>>p[i];
        for(i=0;i<n;i++){
            if(v[i]>V){
                t++;
                for(j=0;j<m;j++){
                    if(p[j]>=d[i])b[j]=1;
                }
            }
        }
        int s;
        cout<<t<<" ";
        for(i=0;i<m;i++)if(!b[i])s++;
        cout<<s<<endl;
    }
    return 0;
}
